//
//  AppDelegate.m
//  GuoKaiZY
//
//  Created by 陈自强 on 16/1/14.
//  Copyright © 2016年 eenet. All rights reserved.
//

#import "AppDelegate.h"

#import "GKZYHomeViewController.h"
#import "GKZYHomeTabBarViewController.h"
#import "GKZYLoginViewController.h"
#import "GKZYLoginUserInfoEntity.h"


@interface AppDelegate ()

@end

@implementation AppDelegate


- (void)applicationInit{
    //    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
    [[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:38/255.f green:109/255.f blue:191/255.f alpha:1]];
    [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
    
    [[UITabBar appearance] setTintColor:[UIColor colorWithRed:38/255.f green:109/255.f blue:191/255.f alpha:1]];
    [[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor], NSFontAttributeName:[UIFont systemFontOfSize:18]}];
    
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.window.backgroundColor = [UIColor whiteColor];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    [self applicationInit];
    
    
    UIViewController *vc = nil;
    
    GKZYLoginUserInfoEntity *loginEntity = [GKZYLoginViewController archiveLogEntity];
    
    //缓存中是否已登录
    if (loginEntity || loginEntity.name) {
        NSUserDefaults *userDeaults = [NSUserDefaults standardUserDefaults];
        [userDeaults setObject:@(YES) forKey:OO_USER_ALREADLY_LOGIN];
        
        GKZYHomeTabBarViewController *tabvc = [[GKZYHomeTabBarViewController alloc]initWithSid:loginEntity.sid];
        vc = tabvc;
    }else{
        GKZYLoginViewController *loginvc = [[GKZYLoginViewController alloc] init];
        vc = loginvc;
    }
    
    UINavigationController *navi = [[UINavigationController alloc]initWithRootViewController:vc];
    navi.navigationBarHidden = YES;
    self.window.rootViewController = navi;
    [self.window makeKeyAndVisible];
    
    return YES;
}

@end
